package cn.exrick.xboot.modules.bicmktbiddinginfo.controller;

import cn.exrick.xboot.common.utils.PageUtil;
import cn.exrick.xboot.common.utils.ResultUtil;
import cn.exrick.xboot.common.vo.PageVo;
import cn.exrick.xboot.common.vo.Result;
import cn.exrick.xboot.common.vo.SearchVo;
import cn.exrick.xboot.modules.biddataproject.entity.SelectData;
import cn.exrick.xboot.modules.bicmktbiddinginfo.entity.*;
import cn.exrick.xboot.modules.bicmktbiddinginfo.service.IBicMktBiddingInfoService;
import cn.hutool.core.util.StrUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;

/**
 * @author sdtf
 */
@Slf4j
@RestController
@DS("other")
@Api(tags = "投标信息管理接口")
@RequestMapping("/xboot/bicMktBiddingInfo")
@Transactional
public class   BicMktBiddingInfoController {

    @Autowired
    private IBicMktBiddingInfoService iBicMktBiddingInfoService;


    //分年投中标数据
    @RequestMapping(value = "/getSanNianbidding/{v}", method = RequestMethod.GET)
    @ApiOperation(value = "年为单位")
    public Result getSanNianbidding(@PathVariable String v){
        List<BidAndBidBack> list = new ArrayList<>();
        if (v.equals("1")) {
            list = iBicMktBiddingInfoService.getSanNianbidding("2024");
        }else if (v.equals("2")){
            list = iBicMktBiddingInfoService.getSanNianbidding("2023");
        }else if (v.equals("3")){
            list = iBicMktBiddingInfoService.getSanNianbidding("2022");
        }
        HashMap<String, Object> map = new HashMap<>();
        List<Object> list1 = new ArrayList<>();
        List<Object> list2 = new ArrayList<>();
        List<Object> list3 = new ArrayList<>();
        List<Object> list4 = new ArrayList<>();
        List<Object> list5 = new ArrayList<>();
        List<Object> list6 = new ArrayList<>();
        List<Object> list7 = new ArrayList<>();
        List<Object> list8 = new ArrayList<>();
        List<Object> list9 = new ArrayList<>();
        for (BidAndBidBack bidAndBidBack: list) {
            list1.add(bidAndBidBack.getBidNumberInProvince());
            list2.add(bidAndBidBack.getBidMoneyInProvince());
            list3.add(bidAndBidBack.getBidBackNumberInProvince());
            list4.add(bidAndBidBack.getBidBackMoneyInProvince());
            list5.add(bidAndBidBack.getBidNumberOutProvince());
            list6.add(bidAndBidBack.getBidMoneyOutProvince());
            list7.add(bidAndBidBack.getBidBackNumberOutProvince());
            list8.add(bidAndBidBack.getBidBackMoneyOutProvince());
            list9.add(bidAndBidBack.getDeptName());
        }
        map.put("l0",list);
        map.put("l1",list1);
        map.put("l2",list2);
        map.put("l3",list3);
        map.put("l4",list4);
        map.put("l5",list5);
        map.put("l6",list6);
        map.put("l7",list7);
        map.put("l8",list8);
        map.put("l9",list9);
        return ResultUtil.data(map);
    }

    /**
     * 以年为单位
     * */
    @RequestMapping(value = "/getShanDongBidding", method = RequestMethod.GET)
    @ApiOperation(value = "省内中标投标金额数量")
    public Result getShanDongBidding(){
        //中投标数量金额本年
        Map<String, Object> stringObjectMap = iBicMktBiddingInfoService.BidAndBidBackNumberAndMoneyByYear();
        return ResultUtil.data(stringObjectMap);
    }

    /**
     * 以月为单位
     * */
    @RequestMapping(value = "/getShanDongBiddingM", method = RequestMethod.GET)
    @ApiOperation(value = "省内中标投标金额数量")
    public Result getShanDongBiddingM(){
        //中投标数量金额本年
        Map<String, Object> stringObjectMap = iBicMktBiddingInfoService.BidAndBidBackNumberAndMoneyByM();
        return ResultUtil.data(stringObjectMap);
    }

    @RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
    @ApiOperation(value = "通过id获取")
    public Result<BicMktBiddingInfo> get(@PathVariable String id) {

        BicMktBiddingInfo bicMktBiddingInfo = iBicMktBiddingInfoService.getById(id);
        return new ResultUtil<BicMktBiddingInfo>().setData(bicMktBiddingInfo);
    }

    @RequestMapping(value = "/getAll", method = RequestMethod.GET)
    @ApiOperation(value = "获取全部数据")
    public Result<List<BicMktBiddingInfo>> getAll() {

        List<BicMktBiddingInfo> list = iBicMktBiddingInfoService.list();
        return new ResultUtil<List<BicMktBiddingInfo>>().setData(list);
    }

    @RequestMapping(value = "/getByPage", method = RequestMethod.GET)
    @ApiOperation(value = "分页获取")
    public Result<IPage<BicMktBiddingInfo>> getByPage(PageVo page) {

        IPage<BicMktBiddingInfo> data = iBicMktBiddingInfoService.page(PageUtil.initMpPage(page));
        return new ResultUtil<IPage<BicMktBiddingInfo>>().setData(data);
    }

    @RequestMapping(value = "/getByCondition", method = RequestMethod.GET)
    @ApiOperation(value = "投标大项目排行多条件分页获取")
    public Result<IPage<BicMktBiddingInfo>> getByCondition(BicMktBiddingInfo bicMktBiddingInfo, SearchVo searchVo, PageVo page) {

        QueryWrapper<BicMktBiddingInfo> qw = new QueryWrapper<>();
        // 统计日期相等匹配
        if (searchVo.getStartDate() != "" && searchVo.getEndDate() != "") {
            String startDate = searchVo.getStartDate();
            String endDate = searchVo.getEndDate();
            qw.between("create_date", startDate, endDate);
        }

        //判断传来的是省内还是省外,如果传进来是一个值
        if (bicMktBiddingInfo.getArealist() != null && bicMktBiddingInfo.getArealist().length == 1) {
            bicMktBiddingInfo.setArea("山东省");
            if ("省内".equals(bicMktBiddingInfo.getArealist()[0])) {
                // area山东省内模糊搜索
                qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getArea()), "area", bicMktBiddingInfo.getArea());
            } else {
                // area山东省外模糊搜索
                qw.notLike(StrUtil.isNotBlank(bicMktBiddingInfo.getArea()), "area", bicMktBiddingInfo.getArea());
            }
        } else {
            // area模糊搜素
            qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getArea()), "area", bicMktBiddingInfo.getArea());
        }

        //判断传来的状态是什么？
        if (bicMktBiddingInfo.getStatuslist() != null && bicMktBiddingInfo.getStatuslist().length == 1) {
            bicMktBiddingInfo.setStatus(bicMktBiddingInfo.getStatuslist()[0]);
            // status模糊搜素
            qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getStatus()), "status", bicMktBiddingInfo.getStatus());
        } else if (bicMktBiddingInfo.getStatuslist() != null && bicMktBiddingInfo.getStatuslist().length == 2) {
            // area模糊搜索
            qw.in("status", bicMktBiddingInfo.getStatuslist());
        } else {
            qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getStatus()), "status", bicMktBiddingInfo.getStatus());
        }

        //判断传来的客户类型
        if (bicMktBiddingInfo.getTypelist() != null && bicMktBiddingInfo.getTypelist().length == 1) {
            String s = bicMktBiddingInfo.getTypelist()[0];
            String[] myArray = {"移动", "联通", "电信", "铁塔"};
            if (!s.equals("集客")) {
                qw.like("fullname", s);
            } else {
                for (String type : myArray) {
                    qw.notLike("fullname", type);
                }
            }
        }
        else if (bicMktBiddingInfo.getTypelist() != null && bicMktBiddingInfo.getTypelist().length > 1 && bicMktBiddingInfo.getTypelist().length < 5) {
            String[] typelist = bicMktBiddingInfo.getTypelist();
            String[] myArray = {"移动", "联通", "电信", "铁塔"};
            List<String> myArrayList = new ArrayList<>(Arrays.asList(myArray));
            // 标志变量，判断是否包含 "集客"
            boolean containsJike = false;

            if (bicMktBiddingInfo.getTypelist() != null && bicMktBiddingInfo.getTypelist().length == 2) {
                //如果传进来两个值
                for (String s1 : myArray) {
                    for (String s : typelist) {
                        if (s.equals(s1)) {
                            myArrayList.remove(s1);
                        }
                        if (s.equals("集客")) {
                            containsJike = true;
                        }
                    }
                }
                Object[] objects = myArrayList.toArray();
                for (Object object : objects) {
                    qw.notLike("fullname", object);
                }
                if (!containsJike) {
                    qw.like("fullname", typelist[0]).or().like("fullname", typelist[1]);
                }
            } else if (bicMktBiddingInfo.getTypelist() != null && bicMktBiddingInfo.getTypelist().length == 3) {
                //如果传进来三个值
                for (String s1 : myArray) {
                    for (String s : typelist) {
                        if (s.equals(s1)) {
                            myArrayList.remove(s1);
                        }
                        if (s.equals("集客")) {
                            containsJike = true;
                        }
                    }
                }
                Object[] objects = myArrayList.toArray();
                for (Object object : objects) {
                    qw.notLike("fullname", object);
                }
                if (!containsJike) {
                    qw.like("fullname", typelist[0]).or().like("fullname", typelist[1]).or().like("fullname", typelist[2]);
                }
            }else {
                //如果传进来四个值
                for (String s1 : myArray) {
                    for (String s : typelist) {
                        if (s.equals(s1)) {
                            myArrayList.remove(s1);
                        }
                        if (s.equals("集客")) {
                            containsJike = true;
                        }
                    }
                }
                Object[] objects = myArrayList.toArray();
                for (Object object : objects) {
                    qw.notLike("fullname", object);
                }
                if (!containsJike) {
                    qw.like("fullname", typelist[0]).or().like("fullname", typelist[1]).or().like("fullname", typelist[2]).or().like("fullname", typelist[3]);
                }
            }
        }
        else {
            qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getFullname()), "fullname", bicMktBiddingInfo.getFullname());
        }
        // biddingId模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getBiddingId()), "bidding_id", bicMktBiddingInfo.getBiddingId());
        // businessId模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getBusinessId()), "business_id", bicMktBiddingInfo.getBusinessId());
        // supplyId模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getSupplyId()), "supply_id", bicMktBiddingInfo.getSupplyId());
        // biddingName模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getBiddingName()), "bidding_name", bicMktBiddingInfo.getBiddingName());
        // chargeOrgName模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getChargeOrgName()), "charge_org_name", bicMktBiddingInfo.getChargeOrgName());
        // companyCode模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getCompanyCode()), "company_code", bicMktBiddingInfo.getCompanyCode());
        // progress模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getProgress()), "progress", bicMktBiddingInfo.getProgress());
        // pmId模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getPmId()), "pm_id", bicMktBiddingInfo.getPmId());
        // isBusiness模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getIsBusiness()), "is_business", bicMktBiddingInfo.getIsBusiness());
        // createId模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getCreateId()), "create_id", bicMktBiddingInfo.getCreateId());
        // createDate模糊搜素
//        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getCreateDate()), "create_date", bicMktBiddingInfo.getCreateDate());
        // modifyId模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getModifyId()), "modify_id", bicMktBiddingInfo.getModifyId());
        // modifyDate模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getModifyDate()), "modify_date", bicMktBiddingInfo.getModifyDate());
        // proxy模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getProxy()), "proxy", bicMktBiddingInfo.getProxy());
        // proxyOrg模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getProxyOrg()), "proxy_org", bicMktBiddingInfo.getProxyOrg());
        // proxyContacts模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getProxyContacts()), "proxy_contacts", bicMktBiddingInfo.getProxyContacts());
        // proxyPost模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getProxyPost()), "proxy_post", bicMktBiddingInfo.getProxyPost());
        // proxyPhone模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getProxyPhone()), "proxy_phone", bicMktBiddingInfo.getProxyPhone());
        // proxyEmail模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getProxyEmail()), "proxy_email", bicMktBiddingInfo.getProxyEmail());
        // biddingMode模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getBiddingMode()), "bidding_mode", bicMktBiddingInfo.getBiddingMode());
        // biddingAppraise模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getBiddingAppraise()), "bidding_appraise", bicMktBiddingInfo.getBiddingAppraise());
        // amount相等匹配
        qw.eq(bicMktBiddingInfo.getAmount() != null, "amount", bicMktBiddingInfo.getAmount());
        // source模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getSource()), "source", bicMktBiddingInfo.getSource());
        // getTime模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getGetTime()), "get_time", bicMktBiddingInfo.getGetTime());
        // estimateTime模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getEstimateTime()), "estimate_time", bicMktBiddingInfo.getEstimateTime());
        // securityDeposit相等匹配
        qw.eq(bicMktBiddingInfo.getSecurityDeposit() != null, "security_deposit", bicMktBiddingInfo.getSecurityDeposit());
        // payOptions模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getPayOptions()), "pay_options", bicMktBiddingInfo.getPayOptions());
        // payMarginTime模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getPayMarginTime()), "pay_margin_time", bicMktBiddingInfo.getPayMarginTime());
        // returnMarginTime模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getReturnMarginTime()), "return_margin_time", bicMktBiddingInfo.getReturnMarginTime());
        // confId模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getConfId()), "conf_id", bicMktBiddingInfo.getConfId());
        // contactsId模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getContactsId()), "contacts_id", bicMktBiddingInfo.getContactsId());
        // biddingCode模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getBiddingCode()), "bidding_code", bicMktBiddingInfo.getBiddingCode());
        // endReason模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getEndReason()), "end_reason", bicMktBiddingInfo.getEndReason());
        // biddingNumber模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getBiddingNumber()), "bidding_number", bicMktBiddingInfo.getBiddingNumber());
        // biddingWorkLoad模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getBiddingWorkLoad()), "bidding_work_load", bicMktBiddingInfo.getBiddingWorkLoad());
        // professional模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getProfessional()), "professional", bicMktBiddingInfo.getProfessional());

        // constructOrgName模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getConstructOrgName()), "construct_org_name", bicMktBiddingInfo.getConstructOrgName());
        // projName模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getProjName()), "proj_name", bicMktBiddingInfo.getProjName());
        // orgCode模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getOrgCode()), "org_code", bicMktBiddingInfo.getOrgCode());
        // estimateProjectAmount相等匹配
        qw.eq(bicMktBiddingInfo.getEstimateProjectAmount() != null, "estimate_project_amount", bicMktBiddingInfo.getEstimateProjectAmount());
        // estimateCostAmount相等匹配
        qw.eq(bicMktBiddingInfo.getEstimateCostAmount() != null, "estimate_cost_amount", bicMktBiddingInfo.getEstimateCostAmount());
        // estimateRate模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getEstimateRate()), "estimate_rate", bicMktBiddingInfo.getEstimateRate());
        // updateTime模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getUpdateTime()), "update_time", bicMktBiddingInfo.getUpdateTime());
        // remark模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getRemark()), "remark", bicMktBiddingInfo.getRemark());
        // finalistNature模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getFinalistNature()), "finalist_nature", bicMktBiddingInfo.getFinalistNature());
        // serviceStartDate模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getServiceStartDate()), "service_start_date", bicMktBiddingInfo.getServiceStartDate());
        // serviceEndDate模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getServiceEndDate()), "service_end_date", bicMktBiddingInfo.getServiceEndDate());
//        qw.inSql("status", "4,2");
        IPage<BicMktBiddingInfo> data = iBicMktBiddingInfoService.page(PageUtil.initMpPage(page), qw);
        return new ResultUtil<IPage<BicMktBiddingInfo>>().setData(data);
    }

    @RequestMapping(value = "/getBidBackByCondition1", method = RequestMethod.GET)
    @ApiOperation(value = "中标大项目排行多条件分页获取")
    public Result<IPage<BicMktBiddingInfo>> getBidBackByCondition1(BicMktBiddingInfo bicMktBiddingInfo, SearchVo searchVo, PageVo page) {

        QueryWrapper<BicMktBiddingInfo> qw = new QueryWrapper<>();
        // 统计日期相等匹配
        if (searchVo.getStartDate() != "" && searchVo.getEndDate() != "") {
            String startDate = searchVo.getStartDate();
            String endDate = searchVo.getEndDate();
            qw.between("create_date", startDate, endDate);
        }
        //判断传来的是省内还是省外,如果传进来是一个值
        if (bicMktBiddingInfo.getArealist() != null && bicMktBiddingInfo.getArealist().length == 1) {
            bicMktBiddingInfo.setArea("山东省");
            if ("省内".equals(bicMktBiddingInfo.getArealist()[0])) {
                // area山东省内模糊搜索
                qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getArea()), "area", bicMktBiddingInfo.getArea());
            } else {
                // area山东省外模糊搜索
                qw.notLike(StrUtil.isNotBlank(bicMktBiddingInfo.getArea()), "area", bicMktBiddingInfo.getArea());
            }
        } else {
            // area模糊搜素
            qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getArea()), "area", bicMktBiddingInfo.getArea());
        }

        //判断传来的状态是什么？
        if (bicMktBiddingInfo.getStatuslist() != null && bicMktBiddingInfo.getStatuslist().length == 1) {
            bicMktBiddingInfo.setStatus(bicMktBiddingInfo.getStatuslist()[0]);
            // status模糊搜素
            qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getStatus()), "status", bicMktBiddingInfo.getStatus());
        } else if (bicMktBiddingInfo.getStatuslist() != null && bicMktBiddingInfo.getStatuslist().length == 2) {
            // area模糊搜索
            qw.in("status", bicMktBiddingInfo.getStatuslist());
        } else {
            qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getStatus()), "status", bicMktBiddingInfo.getStatus());
        }
        // biddingId模糊搜素
        List<String> list  =   iBicMktBiddingInfoService.getbiddingid();
        qw.in( "bidding_id", list);
        // biddingName模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getBiddingName()), "bidding_name", bicMktBiddingInfo.getBiddingName());
        // chargeOrgName模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getChargeOrgName()), "charge_org_name", bicMktBiddingInfo.getChargeOrgName());
        // biddingMode模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getBiddingMode()), "bidding_mode", bicMktBiddingInfo.getBiddingMode());

        IPage<BicMktBiddingInfo> data = iBicMktBiddingInfoService.page(PageUtil.initMpPage(page), qw);
        List<BicMktBiddingInfo> list1  = iBicMktBiddingInfoService.getBidBackTime();
        List<BicMktBiddingInfo> records = data.getRecords();
        for (BicMktBiddingInfo record : records) {
            for (BicMktBiddingInfo mktBiddingInfo : list1) {
                if (mktBiddingInfo.getBiddingId().equals(record.getBiddingId())){
                    record.setCreateDate(mktBiddingInfo.getBidBackTime());
                }
            }
        }
        data.setRecords(records);
        return new ResultUtil<IPage<BicMktBiddingInfo>>().setData(data);
    }

    @RequestMapping(value = "/getBidBackByCondition2", method = RequestMethod.GET)
    @ApiOperation(value = "在标大项目排行多条件分页获取")
    public Result<IPage<BicMktBiddingInfo>> getBidBackByCondition2(BicMktBiddingInfo bicMktBiddingInfo, SearchVo searchVo, PageVo page) {

        QueryWrapper<BicMktBiddingInfo> qw = new QueryWrapper<>();
        // 统计日期相等匹配
        if (searchVo.getStartDate() != "" && searchVo.getEndDate() != "") {
            String startDate = searchVo.getStartDate();
            String endDate = searchVo.getEndDate();
            qw.between("create_date", startDate, endDate);
        }

        //判断传来的是省内还是省外,如果传进来是一个值
        if (bicMktBiddingInfo.getArealist() != null && bicMktBiddingInfo.getArealist().length == 1) {
            bicMktBiddingInfo.setArea("山东省");
            if ("省内".equals(bicMktBiddingInfo.getArealist()[0])) {
                // area山东省内模糊搜索
                qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getArea()), "area", bicMktBiddingInfo.getArea());
            } else {
                // area山东省外模糊搜索
                qw.notLike(StrUtil.isNotBlank(bicMktBiddingInfo.getArea()), "area", bicMktBiddingInfo.getArea());
            }
        } else {
            // area模糊搜素
            qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getArea()), "area", bicMktBiddingInfo.getArea());
        }

        //判断传来的状态是什么？
        if (bicMktBiddingInfo.getStatuslist() != null && bicMktBiddingInfo.getStatuslist().length == 1) {
            bicMktBiddingInfo.setStatus(bicMktBiddingInfo.getStatuslist()[0]);
            // status模糊搜素
            qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getStatus()), "status", bicMktBiddingInfo.getStatus());
        } else if (bicMktBiddingInfo.getStatuslist() != null && bicMktBiddingInfo.getStatuslist().length == 2) {
            // area模糊搜索
            qw.in("status", bicMktBiddingInfo.getStatuslist());
        } else {
            qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getStatus()), "status", bicMktBiddingInfo.getStatus());
        }

        //判断传来的客户类型
        if (bicMktBiddingInfo.getTypelist() != null && bicMktBiddingInfo.getTypelist().length == 1) {
            String s = bicMktBiddingInfo.getTypelist()[0];
            String[] myArray = {"移动", "联通", "电信", "铁塔"};
            if (!s.equals("集客")) {
                qw.like("fullname", s);
            } else {
                for (String type : myArray) {
                    qw.notLike("fullname", type);
                }
            }
        }
        else if (bicMktBiddingInfo.getTypelist() != null && bicMktBiddingInfo.getTypelist().length > 1 && bicMktBiddingInfo.getTypelist().length < 5) {
            String[] typelist = bicMktBiddingInfo.getTypelist();
            String[] myArray = {"移动", "联通", "电信", "铁塔"};
            List<String> myArrayList = new ArrayList<>(Arrays.asList(myArray));
            // 标志变量，判断是否包含 "集客"
            boolean containsJike = false;

            if (bicMktBiddingInfo.getTypelist() != null && bicMktBiddingInfo.getTypelist().length == 2) {
                //如果传进来两个值
                for (String s1 : myArray) {
                    for (String s : typelist) {
                        if (s.equals(s1)) {
                            myArrayList.remove(s1);
                        }
                        if (s.equals("集客")) {
                            containsJike = true;
                        }
                    }
                }
                Object[] objects = myArrayList.toArray();
                for (Object object : objects) {
                    qw.notLike("fullname", object);
                }
                if (!containsJike) {
                    qw.like("fullname", typelist[0]).or().like("fullname", typelist[1]);
                }
            } else if (bicMktBiddingInfo.getTypelist() != null && bicMktBiddingInfo.getTypelist().length == 3) {
                //如果传进来三个值
                for (String s1 : myArray) {
                    for (String s : typelist) {
                        if (s.equals(s1)) {
                            myArrayList.remove(s1);
                        }
                        if (s.equals("集客")) {
                            containsJike = true;
                        }
                    }
                }
                Object[] objects = myArrayList.toArray();
                for (Object object : objects) {
                    qw.notLike("fullname", object);
                }
                if (!containsJike) {
                    qw.like("fullname", typelist[0]).or().like("fullname", typelist[1]).or().like("fullname", typelist[2]);
                }
            }else {
                //如果传进来四个值
                for (String s1 : myArray) {
                    for (String s : typelist) {
                        if (s.equals(s1)) {
                            myArrayList.remove(s1);
                        }
                        if (s.equals("集客")) {
                            containsJike = true;
                        }
                    }
                }
                Object[] objects = myArrayList.toArray();
                for (Object object : objects) {
                    qw.notLike("fullname", object);
                }
                if (!containsJike) {
                    qw.like("fullname", typelist[0]).or().like("fullname", typelist[1]).or().like("fullname", typelist[2]).or().like("fullname", typelist[3]);
                }
            }
        }
        else {
            qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getFullname()), "fullname", bicMktBiddingInfo.getFullname());
        }
        // biddingId模糊搜素
        List<String> list  =   iBicMktBiddingInfoService.getbiddingid();
        qw.notIn( "bidding_id", list);
        // 获取当前时间
        LocalDate now = LocalDate.now();
        // 获取两个月之前的日期
        LocalDate twoMonthsAgo = now.minusMonths(2);
        // 定义日期格式
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
        // 格式化日期为字符串
        String nowString = now.format(formatter);
        String twoMonthsAgoString = twoMonthsAgo.format(formatter);

        qw.between("create_date", twoMonthsAgoString, nowString);
        qw.eq("status", "4");
        // biddingName模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getBiddingName()), "bidding_name", bicMktBiddingInfo.getBiddingName());
        // chargeOrgName模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getChargeOrgName()), "charge_org_name", bicMktBiddingInfo.getChargeOrgName());
        // biddingMode模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getBiddingMode()), "bidding_mode", bicMktBiddingInfo.getBiddingMode());
        // biddingAppraise模糊搜素
        qw.like(StrUtil.isNotBlank(bicMktBiddingInfo.getBiddingAppraise()), "bidding_appraise", bicMktBiddingInfo.getBiddingAppraise());
        // amount相等匹配
        qw.eq(bicMktBiddingInfo.getAmount() != null, "amount", bicMktBiddingInfo.getAmount());
        IPage<BicMktBiddingInfo> data = iBicMktBiddingInfoService.page(PageUtil.initMpPage(page), qw);
        return new ResultUtil<IPage<BicMktBiddingInfo>>().setData(data);
    }

    @RequestMapping(value = "/insertOrUpdate", method = RequestMethod.POST)
    @ApiOperation(value = "编辑或更新数据")
    public Result<BicMktBiddingInfo> saveOrUpdate(BicMktBiddingInfo bicMktBiddingInfo) {

        if (iBicMktBiddingInfoService.saveOrUpdate(bicMktBiddingInfo)) {
            return new ResultUtil<BicMktBiddingInfo>().setData(bicMktBiddingInfo);
        }
        return new ResultUtil<BicMktBiddingInfo>().setErrorMsg("操作失败");
    }

    @RequestMapping(value = "/delByIds", method = RequestMethod.POST)
    @ApiOperation(value = "批量通过id删除")
    public Result delAllByIds(@RequestParam String[] ids) {

        for (String id : ids) {
            iBicMktBiddingInfoService.removeById(id);
        }
        return ResultUtil.success("批量通过id删除数据成功");
    }

    @RequestMapping(value = "/NewBid", method = RequestMethod.GET)
    @ApiOperation(value = "最新中标项目")
    public Result NewBid() {
        List<SelectData> selectData = iBicMktBiddingInfoService.selectNewBid();
        return new ResultUtil<List<SelectData>>().setData(selectData);
    }

    @RequestMapping(value = "/isBidding", method = RequestMethod.GET)
    @ApiOperation(value = "在投重大项目")
    public Result IsBidding() {
        List<SelectData> selectData = iBicMktBiddingInfoService.selectisBidding();
        return new ResultUtil<List<SelectData>>().setData(selectData);
    }

    @RequestMapping(value = "/BidNumber", method = RequestMethod.GET)
    @ApiOperation(value = "本年投中标数")
    public Result BidNumber() {
        SelectData selectData = iBicMktBiddingInfoService.selectBidNumber();
        return new ResultUtil<SelectData>().setData(selectData);
    }

    @RequestMapping(value = "/BidNumberByMonth", method = RequestMethod.GET)
    @ApiOperation(value = "本月投中标数")
    public Result BidNumberByMonth() {
        SelectData selectData = iBicMktBiddingInfoService.BidNumberByMonth();
        return new ResultUtil<SelectData>().setData(selectData);
    }

    @RequestMapping(value = "/Bidding", method = RequestMethod.GET)
    @ApiOperation(value = "正在投标")
    public Result Bidding() {
        SelectData selectData = iBicMktBiddingInfoService.Bidding();
        return new ResultUtil<SelectData>().setData(selectData);
    }

    @RequestMapping(value = "/BidInfo", method = RequestMethod.GET)
    @ApiOperation(value = "本年中标排行")
    public Result BidInfo() {
        List<SelectData> selectData = iBicMktBiddingInfoService.BidInfo();
        return new ResultUtil<List<SelectData>>().setData(selectData);
    }

    @RequestMapping(value = "/BidInfoByMonth", method = RequestMethod.GET)
    @ApiOperation(value = "本月中标排行")
    public Result BidInfoByMonth() {
        List<SelectData> selectData = iBicMktBiddingInfoService.BidInfoByMonth();
        return new ResultUtil<List<SelectData>>().setData(selectData);
    }

    /**
     * 二级菜单：最新中标项目详情本年
     */
    @RequestMapping(value = "/NewBidInformation", method = RequestMethod.GET)
    @ApiOperation(value = "最新中标项目详情本年")
    public Result NewBidInformation(PageVo page) {
        List<BidInfo> selectData = iBicMktBiddingInfoService.NewBidInformation(page);
        return new ResultUtil<List<BidInfo>>().setData(selectData);
    }

    /**
     * 二级菜单：最新中标项目详情本月
     */
    @RequestMapping(value = "/NewBidInformationByMonth", method = RequestMethod.GET)
    @ApiOperation(value = "最新中标项目详情本月")
    public Result NewBidInformationByMonth(PageVo page) {
        List<BidInfo> selectData = iBicMktBiddingInfoService.NewBidInformationByMonth(page);
        return new ResultUtil<List<BidInfo>>().setData(selectData);
    }

    /**
     * 二级菜单：再投重大项目详情本年
     */
    @RequestMapping(value = "/isBiddingInformation", method = RequestMethod.GET)
    @ApiOperation(value = "在投重大项目详情本年")
    public Result isBiddinginformation(PageVo page) {
        List<BidInfo> selectData = iBicMktBiddingInfoService.isBiddingInformation(page);
        return new ResultUtil<List<BidInfo>>().setData(selectData);
    }

    /**
     * 二级菜单：再投重大项目详情本月
     */
    @RequestMapping(value = "/isBiddingInformationByMonth", method = RequestMethod.GET)
    @ApiOperation(value = "在投重大项目详情本月")
    public Result isBiddingInformationByMonth() {
        List<BidInfo> selectData = iBicMktBiddingInfoService.isBiddingInformationByMonth();
        return new ResultUtil<List<BidInfo>>().setData(selectData);
    }

    /**
     * 二级菜单：再投重大项目详情自定义查询
     */
    @RequestMapping(value = "/isBiddingInformationByDate", method = RequestMethod.GET)
    @ApiOperation(value = "在投重大项目详情本月")
    public Result isBiddingInformationByDate(@RequestParam SelectDate selectDate) {
        List<BidInfo> selectData = iBicMktBiddingInfoService.isBiddingInformationByDate(selectDate);
        return new ResultUtil<List<BidInfo>>().setData(selectData);
    }

    /**
     * 二级菜单：投标，中标数量金额详情本年
     */
    @RequestMapping(value = "/BidAndBidBackNumberAndMoney", method = RequestMethod.GET)
    @ApiOperation(value = "投标中标数量金额详情本年")
    public Result BidAndBidBackNumberAndMoney(BidAndBidBack bidtype) {
        List<BidAndBidBack> selectData = iBicMktBiddingInfoService.BidAndBidBackNumberAndMoney(bidtype);
        return new ResultUtil<List<BidAndBidBack>>().setData(selectData);
    }

    /**
     * 二级菜单：投标，中标数量金额详情本月
     */
    @RequestMapping(value = "/BidAndBidBackNumberAndMoneyByMonth", method = RequestMethod.GET)
    @ApiOperation(value = "投标中标数量金额详情本月")
    public Result BidAndBidBackNumberAndMoneyByMonth(BidAndBidBack bidtype) {
        List<BidAndBidBack> selectData = iBicMktBiddingInfoService.BidAndBidBackNumberAndMoneyByMonth(bidtype);
        return new ResultUtil<List<BidAndBidBack>>().setData(selectData);
    }

    /**
     * 二级菜单：正在投标数量，金额
     */
    @RequestMapping(value = "/isBiddingNumAndMoney", method = RequestMethod.GET)
    @ApiOperation(value = "在投重大项目数量，金额本年")
    public Result isBiddingNumAndMoney() {
        List<IsBiddingInfo> selectData = iBicMktBiddingInfoService.isBiddingNumAndMoney();
        return new ResultUtil<List<IsBiddingInfo>>().setData(selectData);
    }

    /**
     * 二级菜单：正在投标数量，金额本月
     */
    @RequestMapping(value = "/isBiddingNumAndMoneyByMonth", method = RequestMethod.GET)
    @ApiOperation(value = "在投重大项目数量，金额本月")
    public Result isBiddingNumAndMoneyByMonth() {
        List<IsBiddingInfo> selectData = iBicMktBiddingInfoService.isBiddingNumAndMoneyByMonth();
        return new ResultUtil<List<IsBiddingInfo>>().setData(selectData);
    }


    /**
     * 三级菜单：获取各部门投标详细信息
     */
    @RequestMapping(value = "/getDeptBidInfo", method = RequestMethod.GET)
    @ApiOperation(value = "获取各部门投标详细信息")
    public Result getDeptInfo(RequestData requestData, PageVo page) {
        List<BidInfo> selectData = iBicMktBiddingInfoService.getDeptInfo(requestData, page);
        return new ResultUtil<List<BidInfo>>().setData(selectData);
    }

    /**
     * 三级菜单：获取各部门中标详细信息
     */
    @RequestMapping(value = "/getDeptBidBackInfo", method = RequestMethod.GET)
    @ApiOperation(value = "获取各部门中标详细信息")
    public Result getDeptBidBackInfo(RequestData requestData, PageVo page) {
        List<BidInfo> selectData = iBicMktBiddingInfoService.getDeptBidBackInfo(requestData, page);
        return new ResultUtil<List<BidInfo>>().setData(selectData);
    }

    /**
     * 三级菜单：获取各部门合同详细信息
     */
    @RequestMapping(value = "/getDeptContractInfo", method = RequestMethod.GET)
    @ApiOperation(value = "获取各部门合同详细信息")
    public Result getDeptContractInfo(RequestData requestData, PageVo page) {
        List<DeptInfo> selectData = iBicMktBiddingInfoService.getDeptContractInfo(requestData, page);
        return new ResultUtil<List<DeptInfo>>().setData(selectData);
    }

    /**
     * 三级菜单：获取各部门在投重大项目详细信息
     */
    @RequestMapping(value = "/getDeptIsBiddingInfo", method = RequestMethod.GET)
    @ApiOperation(value = "获取各部门在投重大项目详细信息")
    public Result getDeptIsBiddingInfo(RequestData requestData, PageVo page) {
        List<BidInfo> selectData = iBicMktBiddingInfoService.getDeptIsBiddingInfo(requestData, page);
        return new ResultUtil<List<BidInfo>>().setData(selectData);
    }
}
